<template>
  <div class="card" :class="{ 'card--clickable': clickable }" @click="handleClick">
    <div class="card__image" v-if="imageSrc">
      <img :src="imageSrc" :alt="title">
    </div>
    <div class="card__content">
    <h3 class="card__title"><span v-text="title"></span></h3>
    <p class="card__description" v-if="description"><span v-text="description"></span></p>
    <div class="card__actions" v-if="$slots.actions">
      <slot name="actions"></slot>
    </div>
  </div>
  </div>
</template>

<script>
export default {
  name: 'Card',
  props: {
    title: {
      type: String,
      required: true
    },
    description: {
      type: String,
      default: ''
    },
    imageSrc: {
      type: String,
      default: ''
    },
    clickable: {
      type: Boolean,
      default: false
    }
  },
  emits: ['click'],
  setup(props, { emit }) {
    const handleClick = () => {
      if (props.clickable) {
        emit('click')
      }
    }
    
    return {
      handleClick
    }
  }
}
</script>

<style scoped>
.card {
  border-radius: 8px;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
  overflow: hidden;
  background-color: white;
  transition: transform 0.3s, box-shadow 0.3s;
}

.card:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
}

.card--clickable {
  cursor: pointer;
}

.card__image img {
  width: 100%;
  height: 200px;
  object-fit: cover;
  display: block;
}

.card__content {
  padding: 1.5rem;
}

.card__title {
  margin: 0 0 0.5rem 0;
  font-size: 1.25rem;
  color: #2c3e50;
}

.card__description {
  margin: 0 0 1rem 0;
  color: #7f8c8d;
  line-height: 1.5;
}

.card__actions {
  margin-top: 1rem;
}

.card__actions ::v-deep(button) {
  margin-right: 0.5rem;
}

.card__actions ::v-deep(button:last-child) {
  margin-right: 0;
}
</style>